<template>
  <div class="gameitem" v-show="isShow">
    <div class="item-status-tooblox" @click="isShow=false">
      <div class="status-ico">
      </div>
    </div>
    <div class="game-item-box" v-loading="isLoading">
      <div class="item" v-for="(item,index) in itemData" :key="index" @click="item.isopen=true">
        <div class="item-info" v-show="!item.isopen">
          <div class="item-icon"><img :src="`http://47.97.102.198/static/itemicon_150px/${item.name}.png`" alt=""></div>
          <div class="item-name text-ellipsis">{{item.name}}</div>
        </div>
        <div style="text-align:center;" class="item-tooblox" v-show="item.isopen">
          <div class="item-close" @click.stop="item.isopen=false"><i class="el-icon-close"></i></div>
          <el-input-number style="width:80px;" v-model="item.num" size="mini" :min="1" label="描述文字"></el-input-number>
          <div style="padding:5px 0;">
            <!-- <el-button size="mini">取消</el-button> -->
            <el-button type="primary" size="mini">拿物品</el-button>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    value: Boolean
  },
  data() {
    return {
      isShow: false,
      isLoading: false,
      itemData: []
    }
  },
  watch: {
    isShow(val) {
      this.$emit('input', val)
    },
    value(val) {
      this.isShow = val
    }
  },
  mounted: function () {
    this.getGameItem()
  },
  methods: {
    getGameItem() {
      this.isLoading = true
      this.$API.getgameitem().then((res) => {
        this.itemData = res.data.map((e) => {
          return { name: e, num: 1, isopen: false }
        })
        this.isLoading = false
      })
    }
  }
}
</script>

<style lang="less" scoped>
@keyframes ani-show {
  0% {
    opacity: 0;
    transform: scale(1.5);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}
@keyframes ani-show2 {
  0% {
    opacity: 0;
    transform: translateX(100px);
  }
  100% {
    opacity: 1;
    transform: translateX(0px);
  }
}
.gameitem {
  position: absolute;
  background: transparent;
  // background: rgba(0, 0, 0, 0.3);
  // z-index: 10;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  .item-status-tooblox {
    animation: ani-show2 0.3s;
    
    cursor: pointer;
    transition: 0.3s;
    background: rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(5px);
    position: absolute;
    height: 80px;
    width: 20px;
    right: 350px;
    z-index: 10;
    border-radius: 20px 0 0 20px;
    top: 40%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 5px 5px 6px 3px rgba(0, 0, 0, 0.1);
    border: solid 1px rgba(0, 0, 0, 0.04);
    border-right: none;
    .status-ico {
      height: 30%;
      width: 4px;
      border-radius: 100px;
      background: rgba(0, 0, 0, 0.08);
    }
  }
  .game-item-box {
    animation: ani-show2 0.3s;
    border-left: solid 1px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    overflow-y: auto;
    position: absolute;
    z-index: 10;
    // border-radius: 6px;
    background: rgba(255, 255, 255, 0.6);
    // height: 300px;
    width: 350px;
    right: 0;
    top: 0;
    bottom: 0;
    // left: 50%;
    // top: 50%;
    // margin-top: -150px;
    // margin-left: -150px;
    box-shadow: 5px 5px 6px 3px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(5px);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    .item {
      font-size: 12px;
      width: 100px;
      height: 120px;
      margin: 5px;
      padding: 10px;
      border-radius: 10px;
      cursor: pointer;
      transition: 0.3s;
      &:hover {
        background: fade(#000, 10%);
      }
      .item-icon {
        display: flex;
        justify-content: center;
        img {
          height: 80%;
          width: 80%;
        }
      }
      .item-name {
        // background: fade(#000, 10%);
        border-radius: 10px;
        margin-top: 5px;
        padding: 5px;
        width: 100%;
        // display: inline-block;
        text-align: center;
      }
      .item-tooblox {
        animation: ani-show 0.3s;
        transition: 0.3s;
        position: relative;
        height: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        .item-close {
          transition: 0.3s;
          position: absolute;
          top: -6px;
          right: 0px;
          color: rgba(255, 255, 255, 0.8);
          padding: 2px 3px;
          border-radius: 100px;
          background: fade(#000, 10%);
          &:hover {
            background: fade(#000, 20%);
          }
        }
      }
      .item-info {
        animation: ani-show 0.3s;
        transition: 0.3s;
        display: flex;
        // justify-content: center;
        flex-direction: column;
      }
    }
    // border: solid 1px rgba(0, 0, 0, 0.1);
  }
}
</style>